﻿using System;
using System.Collections.Generic;
using System.Text;
using SalePartial.IDAL;
using System.Data.SqlClient;
using SalePartial.Model;
using System.Data;

namespace SalePartial.BLL
{
    public class XPInquiry : IXPInquiry
    {

        private IXPInquiry dal = SalePartial.DALFactory.DataAccess.CreateXPInquiry();

        public XPInquiryInfo GetXPInquiry(Guid InquiryID)
        {
            XPInquiryInfo info = null;
            SqlDataReader reader = this.SelectReader(InquiryID);
            if (reader.Read()){
                info = new XPInquiryInfo(reader);
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
            }
            return info;
        }

        public void Delete(XPInquiryInfo info)
        {
            dal.Delete(info.InquiryID);
        }

        public int Delete(Guid InquiryID)
        {
            return dal.Delete(InquiryID);
        }

        //<DataObjectMethod(DataObjectMethodType.Delete)> _
        public int DeleteByAddressID(Guid AddressID)
        {
            return dal.DeleteByAddressID(AddressID);
        }

        //<DataObjectMethod(DataObjectMethodType.Delete)> _
        public int DeleteByCompanyID(Guid CompanyID)
        {
            return dal.DeleteByCompanyID(CompanyID);
        }

        //<DataObjectMethod(DataObjectMethodType.Delete)> _
        public int DeleteByUserID(Guid UserID)
        {
            return dal.DeleteByUserID(UserID);
        }

        //<DataObjectMethod(DataObjectMethodType.Delete)> _
        public int DeleteDynamic(string v_whereCondition)
        {
            return dal.DeleteDynamic(v_whereCondition);
        }

        //<DataObjectMethod(DataObjectMethodType.Insert)> _
        public int Insert(XPInquiryInfo info)
        {
            return dal.Insert(info);
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public DataSet SelectAll()
        {
            return dal.SelectAll();
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public DataSet SelectByAddressID(Guid AddressID)
        {
            return dal.SelectByAddressID(AddressID);
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public DataSet SelectByCompanyID(Guid CompanyID)
        {
            return dal.SelectByCompanyID(CompanyID);
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public DataSet SelectByUserID(Guid UserID)
        {
            return dal.SelectByUserID(UserID);
        }

        //<DataObjectMethod(DataObjectMethodType.Fill)> _
        public DataSet SelectDynamic(string v_whereCondition, string v_orderByExpression)
        {
            return dal.SelectDynamic(v_whereCondition, v_orderByExpression);
        }

        //<DataObjectMethod(DataObjectMethodType.Fill)> _
        public DataSet SelectPaged()
        {
            return dal.SelectPaged();
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public SqlDataReader SelectReader(Guid InquiryID)
        {
            return dal.SelectReader(InquiryID);
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public SqlDataReader SelectReaderByAddressID(Guid AddressID)
        {
            return dal.SelectReaderByAddressID(AddressID);
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public SqlDataReader SelectReaderByCompanyID(Guid CompanyID)
        {
            return dal.SelectReaderByCompanyID(CompanyID);
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public SqlDataReader SelectReaderByUserID(Guid UserID)
        {
            return dal.SelectReaderByUserID(UserID);
        }

        //<DataObjectMethod(DataObjectMethodType.Select)> _
        public DataSet SelectSingle(Guid InquiryID)
        {
            return dal.SelectSingle(InquiryID);
        }

        //<DataObjectMethod(DataObjectMethodType.Update)> _
        public int Update(XPInquiryInfo info)
        {
            return dal.Update(info);
        }
    }
}
